#define CCW_TAG "MAIN"
#include "main.h"
#include "log.h"
#include <string.h>

void show_firmware_info(void)
{
	// system start:
	ccw_dbg_log_d(CCW_TAG, "firmware version: [%s]\r\n", FIRMWARE_VERSION);
}

int ccw_main_loop()
{
	ccw_dbg_log_d(CCW_TAG, "Loop start: \r\n");
	while (1) {
		if (USART_RX_STA & 0x8000) {
			ccw_dbg_log_d(CCW_TAG, "%s\r\n", USART_RX_BUF);
			if (strncmp(USART_RX_BUF, "scdc", 4) == 0) {
				scdc_test();
			} else if (strncmp(USART_RX_BUF, "hdmi", 4) == 0) {
				if (strncmp(USART_RX_BUF + 5, "1", 1) == 0){
					ccw_dbg_log_d(CCW_TAG, "Set HDMI Out Enable\r\n");
					ccw_hdmi_connect(1);
				} else {
					ccw_dbg_log_d(CCW_TAG, "Set HDMI Out Disable\r\n");
					ccw_hdmi_connect(0);
				}
			} else if (strncmp(USART_RX_BUF, "edid", 4) == 0) {
				ccw_hdmi_read_edid();
			}
			USART_RX_STA = 0;
		}
	}
	return 0;
}
